%{

/* Declarations section */
#include "imesh.hpp"
#include "imesh.tab.hpp"
#include <stdio.h>
#include <string.h>

//#define DEBUG_PRINT
void debugPrint(const char* name);
//%option yylineno
%}

%option noyywrap

NUM (-?[1-9][0-9]*)

%%

NUM {
	yylval.vNum = atoi(yytext);
	debugPrint("INT found");
	return F_V;
}

NUM\/NUM {
	sscanf_s(yytext, "%d/%d", &yylval.vNum, &yylval.tNum);
	debugPrint("INT/INT found");
	return F_V_T;
}

NUM\/\/NUM {
	sscanf_s(yytext, "%d//%d", &yylval.vNum, &yylval.nNum);
	debugPrint("INT//INT found");
	return F_V_N;
}

NUM\/NUM\/NUM {
	sscanf_s(yytext, "%d/%d/%d", &yylval.vNum, &yylval.tNum, &yylval.nNum);
	debugPrint("INT/INT/INT found");
	return F_V_T_N;
}

-?[0-9]*(([0-9]\.)|(\.[0-9]))[0-9]* {
    sscanf_s(yytext, "%f", &yylval.fNum);
	debugPrint("FLOAT found");
    return FLOAT;
}

v	return VERTEX;
vn	return NORMAL;
vt	return TXCOORDS;
f	return FACE;

\n	return ENDL;

"#".*          ;
[\t ]         ;
.   errLex();

%%

void debugPrint(const char* name)
{
#ifdef DEBUG_PRINT
	printf("%s - %s\n", name, yytext);
#endif
}
